package gamesys.games.particlesystem.core {
	import gamesys.games.particlesystem.AbstractTest;

	import particlesystem.graphics.BitmapAnimation;
	import particlesystem.graphics.BitmapAnimationFactory;

	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.geom.Point;

	public class BitmapAnimationTest extends AbstractTest {
		private var canvas : Bitmap;
		private var bitmapAnimation : BitmapAnimation;
		private var bitmapAnimationFactory : BitmapAnimationFactory;
		private var animation : Array;

		override protected function init() : void {
			bitmapAnimationFactory = new BitmapAnimationFactory();
			
			animation = bitmapAnimationFactory.getBitmapAnimation("Coin"); 
			
			canvas = new Bitmap(new BitmapData(550, 400));
			bitmapAnimation = new BitmapAnimation(animation);
			
			addChild(canvas);
			
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		private function onEnterFrame(event : Event) : void {
			var frame : BitmapData = bitmapAnimation.getNextFrame();
			
			canvas.bitmapData.fillRect(canvas.bitmapData.rect, 0);
			canvas.bitmapData.copyPixels(frame, frame.rect, new Point(100, 100));
		}
	}
}
